/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.sgsmcan.Dao;

import com.sgsmcan.Entidad.Modulo;
import com.sgsmcan.Hibernate.HibernateUtil;
import com.sgsmcan.Utils.Utilitario;
import java.io.Serializable;
import java.util.List;
import org.hibernate.HibernateException;
import org.hibernate.Query;
import org.hibernate.Session;

/**
 *
 * @author user
 */
public class ModuloDaoImpl extends HibernateDao<Modulo> implements ModuloDao, Serializable{
    
    private final String  CLASE_MODULO = "[ModuloDaoImpl]";
    
    @Override
    public List<Modulo> getModulos() {
        Session session = null;
        List<Modulo> aux;
        try{
            session = HibernateUtil.getSessionFactory().openSession();
            Query query = session.createQuery("from Modulo as module order by module.id");
            aux = query.list();
            return aux;
        }catch(HibernateException e){
            Utilitario.LOG.error(CLASE_MODULO+ " Error al obtener los roles ", e);
            throw new HibernateException(e);
        }finally{
            if(session != null){
                session.close();
            }
        }
    }
    
}
